package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SpBp1;
import com.ruoyi.system.service.ISpBp1Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 编排得分Controller
 * 
 * @author ruoyi
 * @date 2022-11-12
 */
@RestController
@RequestMapping("/system/bp1")
public class SpBp1Controller extends BaseController
{
    @Autowired
    private ISpBp1Service spBp1Service;

    /**
     * 查询编排得分列表
     */
    @PreAuthorize("@ss.hasPermi('system:bp1:list')")
    @GetMapping("/list")
    public TableDataInfo list(SpBp1 spBp1)
    {
        startPage();
        List<SpBp1> list = spBp1Service.selectSpBp1List(spBp1);
        return getDataTable(list);
    }

    /**
     * 导出编排得分列表
     */
    @PreAuthorize("@ss.hasPermi('system:bp1:export')")
    @Log(title = "编排得分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpBp1 spBp1)
    {
        List<SpBp1> list = spBp1Service.selectSpBp1List(spBp1);
        ExcelUtil<SpBp1> util = new ExcelUtil<SpBp1>(SpBp1.class);
        util.exportExcel(response, list, "编排得分数据");
    }

    /**
     * 获取编排得分详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bp1:query')")
    @GetMapping(value = "/{cj1Id}")
    public AjaxResult getInfo(@PathVariable("cj1Id") Long cj1Id)
    {
        return AjaxResult.success(spBp1Service.selectSpBp1ByCj1Id(cj1Id));
    }

    /**
     * 新增编排得分
     */
    @PreAuthorize("@ss.hasPermi('system:bp1:add')")
    @Log(title = "编排得分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpBp1 spBp1)
    {
        return toAjax(spBp1Service.insertSpBp1(spBp1));
    }

    /**
     * 修改编排得分
     */
    @PreAuthorize("@ss.hasPermi('system:bp1:edit')")
    @Log(title = "编排得分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SpBp1 spBp1)
    {
        return toAjax(spBp1Service.updateSpBp1(spBp1));
    }

    /**
     * 删除编排得分
     */
    @PreAuthorize("@ss.hasPermi('system:bp1:remove')")
    @Log(title = "编排得分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cj1Ids}")
    public AjaxResult remove(@PathVariable Long[] cj1Ids)
    {
        return toAjax(spBp1Service.deleteSpBp1ByCj1Ids(cj1Ids));
    }
}
